
 var vm = new Vue({
	 el : '.content',
	 data : {
	 	loginData : {
	 		account : '',
	 		password : '',
	 		code : ''
	 	},
	 	itemType : '01',
	 	applyList : [],
	 	applyTotal : 0,
	 	zhengwuList : [],
	 	zhengwuTotal : 0,
	 	wenjuanList : [],
	 	wenjuanTotal : 0,
	 	consList : [],
	 	consTotal : 0,
		repTabList : [],
		tabConList : [],
		tabConTotal : 0,
		dicList : [],
	 	rightSmartHref : basePath()+'repository/question/smart/smart.html?tabIndex=4'
	 },
	 created : function(){
		 this.$nextTick(function (){
			vm.initData();
		 })
	 },
	 watch : {
		 "tabConTotal" : function(val, oldVal){
			 val.tabConTotal = this.tabConTotal;
		 }
	 },
	 methods : {
	 	initData : function(){
	 		vm.bindDict("DM_XKXMLX");
		 	vm.bindDictRep("REPOSITORY_DL");
		 	vm.initApply();
		 	vm.initNotice();
		 	vm.initzhengwu('01');
			vm.inityuyue();
			vm.initwenjuan();
			vm.initConsulting();
			vm.showRep("01");
			createCode('checkCode');
	 		$(document).on("click",".type",function(){	
				vm.itemType=$(this).attr("id");		
			})	
			vm.fixedRightNav();
	 	},
	 	//政务公示 
	 	initApply : function(){
			myAjax.post({
				url: basePath()+'apply/listHadDone.do',
				contentType : 'application/json',
				data:JSON.stringify({"pageNum":1,"pageSize":10}),
				success: function(data){
					if(data && data.rows){
					  vm.applyList = data.rows;
					  vm.applyTotal = data.total;
					}else{
					  vm.applyList = [];
					  vm.applyTotal = 0;
					}					  
				},
				error : function(){
				  vm.applyList = [];
				  vm.applyTotal = 0;
				}
			});	
	 	},
	 	//公告
	 	initNotice : function(){
//	 		var param = {};
//			param['pageNum'] = 1;
//			param['pageSize'] = 5;
//			param['itemtypecode'] = vm.itemType;
	 		myAjax.post({
				url:basePath()+'notice/list.do',
//				contentType : 'application/json',
//				data:JSON.stringify(param),
				success:function(data){
					if(data && data.rows){
						vm.noticeList = data.rows;
					}else{
						vm.noticeList = [];
					}
				},
				error : function(){
					vm.noticeList = [];
				}
			});
	 	},
		 //政务指南 tab点击函数
	 	zhengwuTabClick : function(type){
			vm.itemType = type;
			vm.initzhengwu(type);		
		},
	 	//政务指南
	 	initzhengwu : function(type){
			var param = {};
			param['pageNum'] = 1;
			param['pageSize'] = 5;
			param['itemtypecode'] = vm.itemType;
			myAjax.post({
				type: 'post',
				url: basePath() + 'declare/list.do',
				contentType : 'application/json',
				data:JSON.stringify(param),
				success: function(data){
					if(data && data.rows){
					  vm.zhengwuList = data.rows;
					  vm.zhengwuTotal = data.total;
//					  vm.$nextTick(function(){
					  	 $("#zhengwuzhinan_gengduo a").attr("href","declareflow/declare/index.html?param="+type); 	
//					  });
					}else{
					  vm.zhengwuList = [];
					  vm.zhengwuTotal = 0;
					}
				},
				error : function(info){
				  vm.zhengwuList = [];
				  vm.zhengwuTotal = 0;
				}
			});
		},
		//问卷
		initwenjuan : function (){
			myAjax.post({
				url: basePath()+ 'question/list.do',
				contentType : 'application/json',
				data:JSON.stringify({"pageNum":1,"pageSize":5,"STATUS":'1'}),
				success: function(data){
					if(data && data.rows){
					  vm.wenjuanList = data.rows;
					  vm.wenjuanTotal = data.total;
					}else{
					  vm.wenjuanList = [];
					  vm.wenjuanTotal = 0;
					}					  
				},
				error : function(){
				  vm.wenjuanList = [];
				  vm.wenjuanTotal = 0;
				}
			});	
		},
		//咨询投诉
		initConsulting : function(){
			myAjax.post({
				url: basePath()+'consulting/list.do',
				contentType : 'application/json',
				data:JSON.stringify({"pageNum":1,"pageSize":5,"publicStatus":'1'}),
				dataType: 'json',
				success: function(data){
					if(data && data.rows){
						vm.consList = data.rows;
						vm.consTotal = data.total;
					}else{
						vm.consList = [];
						vm.consTotal = 0;
					}
				},
				error : function(){
				  vm.consList = [];
				  vm.consTotal = 0;
				}
			});		
		},
	 	//常见问题tab
		bindDictRep : function(dictCode){
			myAjax.get({
				url: basePath() + "share/getDictDetail.do",
				data:{
					dictcode:dictCode
				},
				success: function(data){
					if(data && data.datas){
						vm.repTabList = data.datas;
					}else{
						vm.repTabList = []
					}
		    	},
		    	error : function(){
				  vm.repTabList = [];
				}
			});
		},
		//常见问题
		showRep : function(businessType){
			myAjax.post({
				url: basePath() + 'questions/list.do',
				contentType : 'application/json',
				data:JSON.stringify({"pageNum":1,"pageSize":5,"businessType":businessType}),
				success: function(data){
			  		if(data && data.rows){
			  			vm.tabConTotal = data.total;
						vm.tabConList = data.rows;
						vm.$nextTick(function(){
							$("#rep_wrap>.tab_list").css('display','block');
						});
						if(vm.tabConTotal > 0){
							$("#rep_wrap_more").css('display','block');
						} else {
							$("#rep_wrap_more").css('display','none');
						}
						
					}else{
						vm.tabConList = [];
						vm.tabConTotal = 0;
						$("#rep_wrap_more").css('display','none');
					}		 
				},
		    	error : function(){
				  vm.tabConList = [];
				  vm.tabConTotal = 0;
				  $("#rep_wrap_more").css('display','none');
				}
			});
		},
		//办理
		banli : function(url){
			myAjax.post({
			    url: basePath() + 'user/getUser.do',
				contentType : 'application/json',
				data:JSON.stringify({}),
				dataType: 'json',
				success: function(data){
					if(data.result=="0"){
						alert('请先登录');
					}else{
						window.open(url);
					}
				}
			});
		},
		//ajax获取字典数据
		bindDict : function(dictCode){
			myAjax.get({
				url: basePath() + "share/getDictDetail.do",
				data:{
					dictcode:dictCode
				},
				success: function(data){
					if(data && data.datas){
						vm.dicList = data.datas;
					}else{
						vm.dicList = []
					}	
		    	},
		    	error : function(){
				  vm.dicList = [];
				}	
			});
		},
		//预约
		inityuyue : function(){
			$('#yuyue').bootstrapTable({
				method: 'post',
			    url: basePath() + 'reserve/list.do',
			    pagination: false, //分页
			    dataType: "json",
		        contentType: "application/json",
		        pageList: [10, 20, 50, 100],  //可供选择的每页的行数（*）
		        striped: true,      //是否显示行间隔色
		        sidePagination: "server",
		        ////查询参数,每次调用是会带上这个参数，可自定义                         
		        queryParams:function(params) {
		            return {
		                	pageNum: 1,
		                	pageSize: 5
		                };
		        },
			    columns: [{  
		            field : 'number',  
		            title : '序号',  
		            align : 'center',
		            width : '80px',
		            formatter : function(value, row, index) {  
		                var page = $('#yuyue').bootstrapTable("getPage");  
		                return page.pageSize * (page.pageNumber - 1) + index + 1;  
		            }         
			    }, {
			        field: 'ITEMNAME',
			        title: '预约项目',  
			        align : 'center'
			    }, {
			        field: 'RECORDID',
			        visible : false	        
			    }, {	    	
			        field: 'ORGNAME',
			        title: '预约机构',
			        align : 'center'	
			    }, {
			        field: 'RECORDDATE',
			        title: '预约日期',
				    align : 'center'	        	
			    }, {
			        field: 'RECORDPERIOD',
			        title: '预约时间',
				    align : 'center'
			    }]
			});
		},
		fixedRightNav : function(){			 					
			var rightNav=$(".right_smart"); //得到导航对象
			var rightNav_top_default = parseInt(rightNav.css("top").replace('px',''));//默认高度
			var win=$(window); //得到窗口对象
			var sc=$(document);//得到document文档对象。
			fixedInit();	   //固定左侧导航栏
			win.scroll(function(){
				fixedInit();   
			});
			
			 //固定左侧导航栏
			function fixedInit(){

				//右侧快捷按钮
				if(sc.scrollTop()>=0 && sc.scrollTop()<260){
					rightNav.css('top',rightNav_top_default);
				}else{
					var top = sc.scrollTop()-80;
					rightNav.css('top',top);
				}
			}
		},
	 }
 });
 
 
 $('#btnLogin').click(function(){
	 //window.open("http://csp.msa.gov.cn");
	 //$('#loginModal').modal('show');
	 //alert($('#cspiframe').attr('src'));
	 $("#btnLogin").addClass("hidden");
	 $("#afterLogin").removeAttr("hidden");
	 
 });
 
 $('#workbench').click(function(){
	 self.location.href = "http://cspur.msa.gov.cn/webcenter/portal/csp";
 });
 
 $('#query').click(function(){
//	 self.location.href = "business/query/index.html";
	 window.open("business/query/index.html");
 });
 
 $('#order').click(function(){
//	 self.location.href = "reserve/reserve/index.html";
	 window.open("reserve/reserve/index.html");
 });

 $('#understand').click(function(){
	 console.log(vm.rightSmartHref);
//	 self.location.href = vm.rightSmartHref;
	 window.open(vm.rightSmartHref);
 });

 $('#companymaintain').click(function(){
//	 self.location.href = vm.rightSmartHref;
	 window.open('business/record.html');
 });
//
// function loadFrame(obj){
// 	var url = obj.contentWindow.location.href;
// 	console.log(url)
// }

 
 